package com.neusoft.elmboot.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.neusoft.elmboot.mapper.BusinessMapper;
import com.neusoft.elmboot.po.Business;
import com.neusoft.elmboot.service.BusinessService;

@Service
public class BusinessServiceImpl implements BusinessService{
	
	@Autowired
	private BusinessMapper businessMapper;

	@Override
	public List<Business> listBusinessByOrderTypeId(Integer orderTypeId) {
		return businessMapper.listBusinessByOrderTypeId(orderTypeId);
	}

	@Override
	public Business getBusinessByIdByPass(Integer businessId, String password) {
		return businessMapper.getBusinessByIdByPass(businessId, password);
	}
	
	@Override
	public Business getBusinessById(Integer businessId) {
		return businessMapper.getBusinessById(businessId);
	}

	@Override
	public int saveBusiness(Business business) {
		return businessMapper.saveBusiness(business);
	}
	@Override
	public int updateBusiness(Business business){
		return businessMapper.updateBusiness(business);
	}
	@Override
    public int updateBusinessPassword(Integer businessId, String oldPass, String newPass){
		return businessMapper.updateBusinessPassword(businessId, oldPass,newPass);
	}

	// 新增的方法实现：随机获取商家
	@Override
	public List<Business> listRandomBusinessesByOrderTypeId(Integer orderTypeId, Integer limit) {
	 return businessMapper.listRandomBusinessesByOrderTypeId(orderTypeId, limit);
	 }
	 
	 @Override
	 public List<Business> searchBusinessByName(String name) {
        return businessMapper.findBusinessByName("%" + name + "%");
    }


}
